package com.sfx.concurrent.demo.concurrent.ExcutorService;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-01-26
 * Time: 15:39
 */
@Slf4j(topic = "c.TestSubmit")
public class TestSubmit {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService service = Executors.newFixedThreadPool(2);
        Future<String> future = service.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                log.debug("running...");
                Thread.sleep(1000);
                return "ok";
            }
        });
        Future<String> future1 = service.submit(() -> {
            log.debug("running...");
            Thread.sleep(1000);
            return "ok";
        });
        log.debug("{}",future.get());
    }
}
